<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>
    <div>
      <div></div>
      <div></div>
    </div>
    <div></div>
  </div>
</body>
<script>
  //前序遍历
    function my(root){
      let  res = []
      let stack  = []
      if(root == null){
          return res
      }
      stack.push(root)
      while(stack.length>0){
          let temp = stack.pop()
          res.push(temp.val)
          if(temp.right != null){
              stack.push(temp.right)
          }
          if(temp.left != null){
              stack.push(temp.left)
          }
      }
      return res
    }
    
//中序遍历
    var inorderTraversal = function(root) {
   const res = []
   if(root == null){
       return res
   }
   const stack =[]
   let temp = root
   while(temp != null){
       stack.push(temp)
       temp=temp.left
   }
   while(stack.length>0){
       const temp2 = stack.pop()
       res.push(temp2.val)
        if(temp2.right != null){
            while(temp2.right !=null){
            stack.push(temp2.right)
            temp2.right = temp2.right.left
        }
        }
   }
   return res
};
</script>
</html>